<template>
  <span>
    <div class="mui-numbox" data-numbox-min="1" >
      <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
      <input id="test" class="mui-input-numbox" type="number" value="1" @change="countChanged" ref='numbox'>
      <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
  </span>
</template>


<script>
import mui from '../../lib/js/mui.min.js'
export default {
    mounted(){
        mui('.mui-numbox').numbox()
    },
    methods:{
      //每当文本框数据修改时候 最新数据传递给父组件
      countChanged(){
        // console.log(this.$refs.numbox.value)
        this.$emit('getcount',parseInt(this.$refs.numbox.value))
      }
    },
    props:['max'],
    watch:{
      //属性监听使用JS API设置监听numbox的最大值
      max:function(newVal,oldval){
        mui('.mui-numbox').numbox().setOption('max',newVal)
      }
    }
};
</script>

<style>
</style>
